package rpc

import (
	"fmt"
	"net"
	"net/rpc"
)

type Listen int

func (l *Listen) GetLine(line []byte, ack *bool) error {
	fmt.Println(string(line))
	*ack = true
	return nil
}

func StartServer() {
	addr, err := net.ResolveTCPAddr("tcp", "0.0.0.0:8080")
	if err != nil {
		fmt.Println(err)
	}

	inbound, err := net.ListenTCP("tcp", addr)
	if err != nil {
		fmt.Println(err)
	}

	defer inbound.Close()
	listener := new(Listen)

	rpc.Register(listener)
	rpc.Accept(inbound)
}
